home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / drgnsmth.cpt / Dragonsmith 1.1 / Base files / Utilities / ProcessUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-10  |  1.9 KB  |  47 lines

  1. /*
  2.     ProcessUtils.c
  3.     
  4.     Created    16 Jul 1992
  5.     Modified    08 Aug 1992    Added FSpLaunchApp, LaunchedByFinder, and StartAppInForeground (adapted and
  6.                             moved from EventUtils.c, where it didn't really belong)
  7.             11 Sep 1992    Removed FSpLaunchApp, LaunchedByFinder, and GetFinderPSN ╤ they're not needed
  8.                             by Dragonsmith
  9.                             
  10.     Copyright ⌐ 1992 by Paul M. Hoffman
  11.     Send comments or suggestions to paul.hoffman@um.cc.umich.edu
  12.     
  13.     This source code may be freely used, altered, and distributed in any way as long as:
  14.         1.    It is GIVEN away rather than sold (except as expressly permitted by the author)
  15.         2.    This statement and the above copyright notice are left intact.
  16.  
  17. */
  18.  
  19. #include    "ProcessUtils.h"
  20.  
  21. OSErr StartAppInForeground (Boolean *inForeground)
  22. {
  23.     OSErr                err;
  24.     ProcessSerialNumber    myPSN, frontPSN;
  25.     EventRecord            event;
  26.  
  27.     // According to TechNote #180 ╤
  28.     //    "Some applications like  to put up a ╥splash screen╙ to give the user something to look at while the application
  29.     //    is loading. If your application does this and has the canBackground bit set in the size resource, then it should
  30.     //    call _EventAvail several times (or _WaitNextEvent or _GetNextEvent) before putting up the splash screen, or
  31.     //    the splash screen will come up behind the frontmost layer.  If the canBackground bit is set, MultiFinder will not
  32.     //    not move your layer to the front until you call _GetNextEvent, _WaitNextEvent, or _EventAvail"
  33.     // The magic number "several" apparently == 3
  34.  
  35.     // When you call WaitNextEvent, it's a use-it-or-lose-it deal (it == the event returned), so we call EventAvail instead
  36.     
  37.     (void) EventAvail (everyEvent, &event);
  38.     (void) EventAvail (everyEvent, &event);
  39.     (void) EventAvail (everyEvent, &event);
  40.     
  41.     // Now check to see if we actually ARE in the foreground╔
  42.     if ((err = GetCurrentProcess (&myPSN)) == noErr && (err = GetFrontProcess (&frontPSN)) == noErr)
  43.         err = SameProcess (&myPSN, &frontPSN, inForeground);
  44.     return err;
  45. }
  46.  
  47.